<extend name="Base/common"/>
<!--<script type="text/javascript" src="/SG_Shopwechat/Public/Home/js/iscroll.js"></script>-->
<block name="TITLE"><title>采购端</title></block>
<block name="body" >
    <header data-am-widget="header" class="am-header am-header-default am-header-fixed">
        <div class="am-header-left am-header-nav">
            <!--<a href="{:U('Purchase/index')}" class="">-->
                <!--<i class="am-header-icon am-icon-home" style="font-size: 40px;"></i>-->
            <!--</a>-->
        </div>
        <h1 class="am-header-title">
            <a href="#title-link" class="">
                &nbsp;{$meta_title}
            </a>
        </h1>
    </header>
    <!-- 数据列表 -->
    <div class="" style="font-size: 15px;">
        <table id="inventoryTable" class="am-table am-table-striped">
            <thead>
            <tr>
                <!--<th>ID</th>-->
                <!--<th>商品分类</th>-->
                <!--<th>商品编号</th>-->
                <th>商品名称</th>
                <th>规格</th>
                <th>库存数量</th>
                <th>最后盘点时间</th>
                <!--<th>操作</th>-->
            </tr>
            </thead>
            <tfoot>
            <tr>
                <!--<th>商品分类</th>-->
                <!--<th>商品编号</th>-->
                <th>商品名称</th>
                <th>规格</th>
                <th>库存数量</th>
                <th>最后盘点时间</th>
                <!--<th>操作</th>-->
            </tr>
            </tfoot>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <!--<td>{$vo.classname}</td>-->
                        <!--<td>{$vo.spu}</td>-->
                        <td>{$vo.pname}</td>
                        <td>{$vo.spec}</td>
                        <td>{$vo.cnt}</td>
                        <td>{$vo.updateAt|time_format=###,'Y-m-d'}</td>
                        <!--<td>-->
                            <!--<a data-pid="{$vo.pid}" data-pname="{$vo.pname}" data- class="am-btn am-btn-xs am-btn-default purchase">加入预购单</a>-->
                        <!--</td>-->
                    </tr>
                </volist>
                <else/>
                <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>

    <div class="am-modal am-modal-confirm" tabindex="-1" id="mymodal">
        <div class="am-modal-dialog">
            <div class="am-modal-hd ">添加到预购单
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <div class="am-modal-bd">
                <form id="reportForm" action="{:U('addpurchase')}" method="post">
                    <input type="hidden" name="batch" id="batch" value="{$batch}">
                    <input type="hidden" name="pid" id="pid" value="">
                    <div class="am-form-group am-g am-margin-bottom-xs">
                        <label class="am-u-md-3 am-form-label">商品名称</label>
                        <div class="am-u-md-9">
                            <input class="am-form-field " readonly name="proName" id="proName" type="text" placeholder="输入商品名称" />
                        </div>
                    </div>
                    <div class="am-form-group am-g am-margin-bottom-xs" >
                        <label for="spec" class="am-u-md-3 am-form-label">单件规格</label>
                        <div class="am-u-md-3">
                            <input class="am-form-field" name="spec" id="spec" type="hidden"  placeholder="输入单箱规格" value="{$purchase.spec}"/>
                            <input class="reset" name="head" id="head" type="text" />
                        </div>
                        <label for="spec" class="am-u-md-1 am-form-label">头</label>
                        <div class="am-u-sm-3">
                            <input class="reset" name="jin" id="jin" type="text"  value="{$purchase.jin}"/>
                        </div>
                        <label for="spec" class="am-u-sm-1 am-form-label">斤</label>
                    </div>
                    <div class="am-form-group am-g am-margin-bottom-xs">
                        <label for="grossWeight" class="am-u-md-3 am-form-label">总重量</label>
                        <div class="am-u-md-9">
                            <input class="am-form-field reset" name="grossWeight" id="grossWeight" type="text"  placeholder="输入总重量 斤" value="{$purchase.grossWeight}"/>
                        </div>
                    </div>
                    <div class="am-form-group am-g am-margin-bottom-xs">
                        <label for="number" class="am-u-sm-3 am-form-label">采购件数</label>
                        <div class="am-u-sm-9">
                            <input class="am-form-field reset" name="number" id="number" type="text"  placeholder="输入采购件数" value="{$purchase.number}"/>
                        </div>
                    </div>

                </form>
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn" data-am-modal-cancel>取消</span>
                <span class="am-modal-btn" data-am-modal-confirm>确定</span>
            </div>
        </div>
    </div>

</block>
<block name="script">
    <script>
        $(function(){
           $("#inventoryTable").DataTable({
               language: {
                   search: "查询:",
                   lengthMenu:    "每页显示 _MENU_ 条",
                   info:           "当前  _START_ - _END_ 条，共 _TOTAL_ 条",
                   paginate: {
                       first:      "第一页",
                       previous:   "上一页",
                       next:       "下一页",
                       last:       "最后一页"
                   },
               }
                   });
           $(".purchase").click(function(){
               var pid = $(this).data('pid');
               var pname = $(this).data('pname');
               $(".reset").val("");
               $("#proName").val(pname);
               $("#pid").val(pid);
               $("#mymodal").modal({
                   relatedTarget: this,
                   onConfirm: function() {
                           $("#reportForm").submit();
                   },
                   onCancel: function() {
                   }
               });
           })
        });
    </script>
</block>